package com.czf.personal.controller;

import com.czf.common.util.AjaxResult;
import com.czf.personal.service.ModelServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author chenzhanfan
 * @Date 2022/4/22
 * @Description
 */
@RestController
@Slf4j
@CrossOrigin
@RequestMapping("/score")
public class ScoreComputeController {

    @Autowired
    private ModelServiceImpl modelService;

    @RequestMapping(value = "/userModelScore",method = RequestMethod.GET)
    public AjaxResult getModelScore(Long userId) {
        int baseInfoScore = modelService.getUserBaseInfoScore(userId);
        int economicScore = modelService.getEconomicScore(userId);
        int liveScore = modelService.getLiveScore(userId);
        int bankScore = modelService.getBankScore(userId);
        int softwareScore = modelService.getSoftwareScore(userId);
        int[] ints = new int[]{baseInfoScore,economicScore,liveScore,bankScore,softwareScore};
        return AjaxResult.success(ints);
    }

    @RequestMapping(value = "/score",method = RequestMethod.GET)
    public AjaxResult getScore(Long userId) {
        float score = modelService.getScore(userId);
        return AjaxResult.success(score);
    }
}
